package ssm.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import ssm.model.CleanDateMapper;
import ssm.model.TrackMapper;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 原意为整合数据而创 现在已经废弃
 */
@Service
public class CleanDateServiceImpl implements CleanDateService {

    @Autowired
    private CleanDateMapper cleanDateMapper;
    @Autowired
    private TrackMapper trackMapper;

    public void update_business() {
        String maxTime = trackMapper.finMaxTime();
        int hour = 0;
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            Date time = sdf.parse(maxTime);
            hour = (int) (System.currentTimeMillis() - time.getTime()) / (3600 * 1000);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        cleanDateMapper.update_business(hour);
    }

    public void history_business() {
        cleanDateMapper.history_business();
    }
}
